# 导入包
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# 1.导入鼠标操作的类
from selenium.webdriver.common.action_chains import ActionChains
# 获取浏览器驱动
driver = webdriver.Firefox()
driver.maximize_window()
# 打开测试的页面
url = 'file:///root/NSD2408/html/registerA.html'
driver.get(url)
# 2.创建鼠标操作对象，基于指定的浏览器
action = ActionChains(driver)
# 定位用户名，输入内容
username = driver.find_element(By.CSS_SELECTOR, '#userA')
username.send_keys('hello')
sleep(2)
# 3.在用户名这项执行右击
# perform()  执行以上的操作
action.context_click(username).perform()

button = driver.find_element(By.CSS_SELECTOR, '[type="submitA"]')
sleep(3)
# 4.鼠标悬停
action.move_to_element(button).perform()

sleep(3)
# 4.双击
action.double_click(username).perform()

# 关闭浏览器
sleep(3)
driver.quit()